home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 526-550 / disk_541 / steal / src / icon2gadget.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  84 lines

  1. /******************************************************************************************************
  2.  
  3.                     Icon2Gadget.c
  4.  
  5.     This file reads an icon from the disk and places it in a Window, where it will be set up
  6.     as a Gadget. This can now be clicked from Steal to get a Gadget's representation of the
  7.     icon. Unfortunately, this cannot be done from the WorkBench, as WorkBench does not make
  8.     it's icons hang from IntuitionBase.
  9.  
  10.                             Rick van Rein, Februari 7, 1991
  11.  
  12. ******************************************************************************************************/
  13.  
  14.  
  15.  
  16. #include <functions.h>
  17. #include <intuition/intuition.h>
  18. #include <workbench/workbench.h>
  19.  
  20.  
  21. struct NewWindow nwin =
  22.  {
  23.    0, 0, 0, 0,
  24.    -1, -1,
  25.    CLOSEWINDOW,
  26.    SMART_REFRESH | WINDOWDEPTH | WINDOWCLOSE | WINDOWDRAG,
  27.    NULL,
  28.    NULL,
  29.    (UBYTE *) "Icon2Gadget",
  30.    NULL,
  31.    NULL,
  32.    -1, -1, -1, -1,
  33.    WBENCHSCREEN
  34.  };
  35.  
  36. extern void *IconBase;
  37.  
  38. void *IntuitionBase;
  39.  
  40.  
  41. main (argc,argv)
  42.    int argc;
  43.    char *argv [];
  44.  {
  45.    struct DiskObject *dob;
  46.    struct Window *win;
  47.  
  48.    if (argc != 2)
  49.       puts ("\tIcon2Gadget: Please 1 argument: An iconfile without \".info\"");
  50.    else
  51.     {
  52.       IntuitionBase = OpenLibrary ("intuition.library", 0L);    /* This call will succeed always */
  53.       if (!(IconBase = OpenLibrary ("icon.library", 0L)))
  54.          puts ("\tIcon2Gadget: Can't open icon.library");
  55.       else
  56.        {
  57.          if (dob = GetDiskObject (argv [1]))
  58.       {
  59.         nwin.FirstGadget = &dob->do_Gadget;
  60.         nwin.Width = 10 + dob->do_Gadget.Width;
  61.         if (nwin.Width < 100)
  62.            nwin.Width = 100;
  63.         nwin.Height = 20 + dob->do_Gadget.Height;
  64.         dob->do_Gadget.LeftEdge = 5;
  65.         dob->do_Gadget.TopEdge = 15;
  66.         dob->do_Gadget.NextGadget = NULL;
  67.         if (win = OpenWindow (&nwin))
  68.          {
  69.            WaitPort (win->UserPort);        /* Wait for CLOSEWINDOW message over IDCMP */
  70.            ReplyMsg (GetMsg (win->UserPort));
  71.            CloseWindow (win);
  72.          }
  73.         else
  74.            puts ("\tIcon2Gadget: Can't open Window for Gadget");
  75.         FreeDiskObject (dob);
  76.       }
  77.      else
  78.         puts ("\tIcon2Gadget: Can't find the given iconfile");
  79.          CloseLibrary (IconBase);
  80.        }
  81.       CloseLibrary (IntuitionBase);
  82.     }
  83.  }
  84.